package bairui.international.console.web.controller.finance.withdraw;

/**
 * @see bairui.international.console.web.controller.finance.withdraw.Page_BaseFilter
 *
 */
class Page_Filter

{
	
	/**
	 * 过滤扩展接口
	 */
	static interface FilterExtends {
		com.querydsl.core.types.Predicate gainNickName(
			String nickName
		);
		com.querydsl.core.types.Predicate gainRealName(
			String realName
		);
		com.querydsl.core.types.Predicate gainPhone(
			String phone
		);
	}
	
	final static com.querydsl.core.BooleanBuilder query(
		bairui.international.model.domain.jpa.QTB_BranchCompanyWithdrawOrder QRoot,
		javax.servlet.http.HttpServletRequest request
		,FilterExtends filterExtends
	) {
		com.querydsl.core.BooleanBuilder query = query(
				QRoot
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("number"), 
						String.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("accountNumber"), 
						String.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("bank"), 
						String.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("submitDate_start"), 
						java.util.Date.class, 
						"yyyy-MM-dd"
					),
				com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("submitDate_end"), 
						java.util.Date.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("state"), 
						bairui.international.model.status.State_BranchCompanyWithdrawOrder.class, 
						"yyyy-MM-dd"
					)
			);
			/* comment 附加过滤属性 */
			if(null != request.getParameter("nickName")){
				query.and(filterExtends.gainNickName(
					com.sh_lianjing.string.util.Util_String.parseToType(
							request.getParameter("nickName"), 
							String.class, 
							"yyyy-MM-dd"
						)
				));
			}
			if(null != request.getParameter("realName")){
				query.and(filterExtends.gainRealName(
					com.sh_lianjing.string.util.Util_String.parseToType(
							request.getParameter("realName"), 
							String.class, 
							"yyyy-MM-dd"
						)
				));
			}
			if(null != request.getParameter("phone")){
				query.and(filterExtends.gainPhone(
					com.sh_lianjing.string.util.Util_String.parseToType(
							request.getParameter("phone"), 
							String.class, 
							"yyyy-MM-dd"
						)
				));
			}
	;
		return query;
	}
	
	final static com.querydsl.core.BooleanBuilder query(
		bairui.international.model.domain.jpa.QTB_BranchCompanyWithdrawOrder QRoot
	,	String number
	,	String accountNumber
	,	String bank
	,	java.util.Date submitDate_start,
		java.util.Date submitDate_end
	,	bairui.international.model.status.State_BranchCompanyWithdrawOrder state
	) {
		com.querydsl.core.BooleanBuilder builder = new com.querydsl.core.BooleanBuilder();
	
		if(null != number){
			builder.and(QRoot.number.like("%"+number+"%"));
		}
		if(null != accountNumber){
			builder.and(QRoot.accountNumber.like("%"+accountNumber+"%"));
		}
		if(null != bank){
			builder.and(QRoot.bank.like("%"+bank+"%"));
		}
		if(null != submitDate_start && null != submitDate_end){
			builder.and(QRoot.submitDate.between(submitDate_start, submitDate_end));
		}
		if(null != state){
			builder.and(QRoot.state.eq(state));
		}
		return builder;
	}
	
}
